package com.lagou.springboot_work.service;
import com.lagou.springboot_work.pojo.Article;
import com.lagou.springboot_work.repository.ArticleRepository;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {
    @Autowired
    private ArticleRepository articleRepository;

    public Page<Article> findArticle(Integer pageNum, Integer pageSize){
        Pageable pageRequest = PageRequest.of(pageNum-1,pageSize, Sort.Direction.ASC,"id");
        return articleRepository.findAll(pageRequest);
    }
}
